package yaty.lee.tencent.weibo.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Logger;

public class OAuthPropertiesUtil {
    private static final Logger log = Logger.getLogger(OAuthPropertiesUtil.class.getName());
    private static Properties prop = new Properties();

    static {
        String oauthFileName = "tencentMiniBlogOAuth.properties";
        InputStream in = null;
        try {
            in = OAuthPropertiesUtil.class.getClassLoader().getResourceAsStream(oauthFileName);
            prop.load(in);
        } catch (IOException e) {
            log.info("加载" + oauthFileName + "失败！");
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private OAuthPropertiesUtil() {
    }

    public static String getKey() {
        return prop.getProperty("key").trim();
    }

    public static String getSecret() {
        return prop.getProperty("secret").trim();
    }

    public static String getAuthorizeRedirectUri() {
        return prop.getProperty("authorizeRedirectUri").trim();
    }

    public static int getSyncflag() {
        return Integer.parseInt(prop.getProperty("syncflag", "0").trim());
    }
}
